#!/sbin/openrc-run

supervisor=supervise-daemon

name="Woodpecker CI server"

command="/usr/bin/woodpecker-server"
command_user="woodpecker:woodpecker"
directory="/var/lib/woodpecker"

error_log="/var/log/woodpecker/server.log"

depend() {
	need net
	after firewall
}

start_pre() {
	checkpath -f -m 640 -o "woodpecker:woodpecker" /etc/woodpecker/server.conf
	checkpath -d -m 755 -o "woodpecker:woodpecker" /var/lib/woodpecker
	checkpath -f -m 644 -o "woodpecker:woodpecker" /var/log/woodpecker/server.log

	# Source and export configuration variables
	set -a
	source /etc/woodpecker/server.conf
	set +a
}
